Skip to contentSkip to conversation

Change in openvpn[master]: gremlin: Avoid some conversion warnings

Openvpn-devel Superseded flichtenheld (Code Review) 2 participants 6 messages Oct 20, 2025 – Oct 28, 2025 1 message not in the archive

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1760967063000.I2554b9baec6af191b0adb137e64124586dc4331c@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1286?usp=email

to review the following change.

Change subject: gremlin: Avoid some conversion warnings
......................................................................

gremlin: Avoid some conversion warnings

We know these casts are safe, so make
them explicit.

Change-Id I2554b9baec6af191b0adb137e64124586dc4331c

---
M src/openvpn/gremlin.c

1 file changed, 2 insertions(+), 11 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/86/1286/1

src/openvpn/gremlin.c +2 -11
index 0e5e93f..a3dbff1 100644
@@ -98,11 +98,6 @@
     return (get_random() % n) == 0;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 /*
  * Return uniformly distributed random number between
  * low and high.
@@ -112,7 +107,7 @@
 {
     int ret;
     ASSERT(low <= high);
-    ret = low + (get_random() % (high - low + 1));
+    ret = low + (int)(get_random() % (high - low + 1));
     ASSERT(ret >= low && ret <= high);
     return ret;
 }
@@ -195,7 +190,7 @@
             {
                 if (buf->len > 0)
                 {
-                    uint8_t r = roll(0, 255);
+                    uint8_t r = (uint8_t)roll(0, 255);
                     int method = roll(0, 5);
 
                     switch (method)
@@ -235,8 +230,4 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 #endif /* ifdef ENABLE_DEBUG */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1286?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2554b9baec6af191b0adb137e64124586dc4331c
Gerrit-Change-Number: 1286
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1286?usp=email )

Change subject: gremlin: Avoid some conversion warnings
......................................................................

Patch Set 2: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1286?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2554b9baec6af191b0adb137e64124586dc4331c
Gerrit-Change-Number: 1286
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 28 Oct 2025 18:39:24 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH v2 1/1 gremlin: Avoid some conversion warnings

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

We know these casts are safe, so make
them explicit.

Change-Id I2554b9baec6af191b0adb137e64124586dc4331c

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1286
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1286
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/gremlin.c +2 -11
index 0e5e93f..a3dbff1 100644
@@ -98,11 +98,6 @@
     return (get_random() % n) == 0;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 /*
  * Return uniformly distributed random number between
  * low and high.
@@ -112,7 +107,7 @@
 {
     int ret;
     ASSERT(low <= high);
-    ret = low + (get_random() % (high - low + 1));
+    ret = low + (int)(get_random() % (high - low + 1));
     ASSERT(ret >= low && ret <= high);
     return ret;
 }
@@ -195,7 +190,7 @@
             {
                 if (buf->len > 0)
                 {
-                    uint8_t r = roll(0, 255);
+                    uint8_t r = (uint8_t)roll(0, 255);
                     int method = roll(0, 5);
 
                     switch (method)
@@ -235,8 +230,4 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 #endif /* ifdef ENABLE_DEBUG */
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: gremlin: Avoid some conversion warnings

Your patch has been applied to the master branch.

commit 15b77d47f5a9dc78615cdafc50bbb05d5a21c3d6

Author: Frank Lichtenheld
Date:   Tue Oct 28 19:39:35 2025 +0100
     gremlin: Avoid some conversion warnings

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1286
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg33964.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#3) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1286?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: gremlin: Avoid some conversion warnings
......................................................................

gremlin: Avoid some conversion warnings

We know these casts are safe, so make
them explicit.

Change-Id I2554b9baec6af191b0adb137e64124586dc4331c

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1286
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33964.html

---
M src/openvpn/gremlin.c

1 file changed, 2 insertions(+), 11 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/86/1286/3

src/openvpn/gremlin.c +2 -11
index 0e5e93f..a3dbff1 100644
@@ -98,11 +98,6 @@
     return (get_random() % n) == 0;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 /*
  * Return uniformly distributed random number between
  * low and high.
@@ -112,7 +107,7 @@
 {
     int ret;
     ASSERT(low <= high);
-    ret = low + (get_random() % (high - low + 1));
+    ret = low + (int)(get_random() % (high - low + 1));
     ASSERT(ret >= low && ret <= high);
     return ret;
 }
@@ -195,7 +190,7 @@
             {
                 if (buf->len > 0)
                 {
-                    uint8_t r = roll(0, 255);
+                    uint8_t r = (uint8_t)roll(0, 255);
                     int method = roll(0, 5);
 
                     switch (method)
@@ -235,8 +230,4 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 #endif /* ifdef ENABLE_DEBUG */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1286?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2554b9baec6af191b0adb137e64124586dc4331c
Gerrit-Change-Number: 1286
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1286?usp=email )

Change subject: gremlin: Avoid some conversion warnings
......................................................................

gremlin: Avoid some conversion warnings

We know these casts are safe, so make
them explicit.

Change-Id I2554b9baec6af191b0adb137e64124586dc4331c

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1286
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33964.html

---
M src/openvpn/gremlin.c

1 file changed, 2 insertions(+), 11 deletions(-)
src/openvpn/gremlin.c +2 -11
index 0e5e93f..a3dbff1 100644
@@ -98,11 +98,6 @@
     return (get_random() % n) == 0;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 /*
  * Return uniformly distributed random number between
  * low and high.
@@ -112,7 +107,7 @@
 {
     int ret;
     ASSERT(low <= high);
-    ret = low + (get_random() % (high - low + 1));
+    ret = low + (int)(get_random() % (high - low + 1));
     ASSERT(ret >= low && ret <= high);
     return ret;
 }
@@ -195,7 +190,7 @@
             {
                 if (buf->len > 0)
                 {
-                    uint8_t r = roll(0, 255);
+                    uint8_t r = (uint8_t)roll(0, 255);
                     int method = roll(0, 5);
 
                     switch (method)
@@ -235,8 +230,4 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 #endif /* ifdef ENABLE_DEBUG */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1286?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2554b9baec6af191b0adb137e64124586dc4331c
Gerrit-Change-Number: 1286
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>